/**
 * File    : CreatePersona.java
 * Created : 2008-10-19
 * By      : LuHuiguo
 */
package com.luhuiguo.sso.web.pages.secure.persona;

import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.luhuiguo.sso.entity.Persona;
import com.luhuiguo.sso.entity.User;
import com.luhuiguo.sso.service.UserManager;

/**
 * @author LuHuiguo
 * @version $Id: CreatePersona.java 20 2008-10-19 15:43:48Z LuHuiguo $
 *
 */
public class CreatePersona {
	
	@Inject
	private UserManager userManager;
	
	@Persist
	private Long userId;
	
	private User user;
	
	@Property
	private Persona persona;
	
	
	@OnEvent(EventConstants.ACTIVATE)
	void onActivate(Long userId) {
		this.userId = userId;
		user = userManager.getUser(userId);
	}
	
	@OnEvent(value = Form.VALIDATE_FORM, component = "personaForm")
	void onValidateForm() {
		
	}
	
	@OnEvent(EventConstants.PASSIVATE)
	Long onPassivate() {
		return user.getId();
	}		
	
	@OnEvent(value = Form.SUCCESS, component = "personaForm")
	Object onSuccess() {
		
		return null;
		
	}
	
	
	
	
	
	

	
	
	

}
